package com.woniuxy.yuekeuser.service.impl;

import com.woniuxy.yuekeuser.dao.TOrderMapper;
import com.woniuxy.yuekeuser.model.Order;
import com.woniuxy.yuekeuser.dao.OrderMapper;
import com.woniuxy.yuekeuser.model.TOrder;
import com.woniuxy.yuekeuser.service.IOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Freedom
 * @since 2020-11-03
 */
@Slf4j
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private TOrderMapper tOrderMapper;

    @Override
    public int placeOrder(TOrder tOrder) {
        tOrderMapper.insert(tOrder);
        int id = tOrder.getOrderId();
        log.info("返回自增id{}", id);
        return id;
    }

    @Override
    public List<Order> findBusinesOrder(int userId, String state, int index, int size) {
        return orderMapper.findBusinesOrder(userId, state, index, size);
    }

    @Override
    public int findBusinesOrderCount(int userId, String state) {
        return orderMapper.findBusinesOrderCount(userId, state);
    }

    @Override
    public List<Order> findOrderall() {
        return null;
    }

    @Override
    public void deleteOrderByOrder(Order order) {

    }

    @Override
    public void changeOrderState(TOrder order) {
        log.info("插入数据库的信息为{}", order);
        tOrderMapper.updateById(order);
    }

}
